//
// Created by diffdministrator on 2023/11/14.
//
#include "iostream"

using namespace std;

int main() {
    int m, n, q;
    cin >> n >> m >> q;
    int diff[n + 1][m + 1], sum[n + 1][m + 1];
    int ans[q];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j){
            diff[i][j]=0;
            sum[i][j]=0;
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> diff[i][j];
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + diff[i][j];
        }
    }

    int x1, x2, y1, y2;
    for (int i = 0; i < q; ++i) {
        cin >> x1 >> y1 >> x2 >> y2;
        ans[i]=sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
    }
    for (int i = 0; i < q; ++i) {
        cout<<ans[i]<<endl;
    }
}